package controller;

import dao.ArticleDao;
import model.Article;
import jakarta.servlet.*;
import jakarta.servlet.http.*;
import java.io.IOException;

public class ArticleDetailServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String idStr = request.getParameter("id");
        if (idStr != null) {
            int id = Integer.parseInt(idStr);
            ArticleDao dao = new ArticleDao();
            Article article = dao.getArticleById(id);

            request.setAttribute("article", article);
            request.getRequestDispatcher("articleDetail.jsp").forward(request, response);
        }
    }
}
